package com.supersoul.myself.entity;

import com.supersoul.myself.entity.base.BaseEntity;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;

@Data
@Entity
@Table(name = "tb_blog_collection")
@SQLDelete(sql = "update tb_blog_collection set is_delete = 1 where id = ?")
@Where(clause = "is_delete = 0")
public class BlogCollection extends BaseEntity {

    @Column(name = "blog_id", nullable = false, length = 64, columnDefinition = "varchar(64) comment '博客id' ")
    @NotEmpty(message = "blogId不能为null或''")
    @Size(max = 64, message = "blogId不能超过64个字")
    private String blogId;

    @Column(name = "title", nullable = false, length = 20)
    @NotEmpty(message = "title不能为null或''")
    @Size(max = 20, message = "title不能超过20个字")
    private String title;

    // 记录操作数据的人的信息,方便追踪
    // 操作人信息
    @Column(name = "creator_id", nullable = false, length = 64)
    @Size(max = 64, message = "creatorId不能超过64个字")
    private String creatorId;

    @Column(name = "creator_name", nullable = false, length = 20)
    @Size(max = 20, message = "creatorName不能超过20个字")
    public String creatorName;

}
